package com.genesis.yunnanji.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * @author: Kite
 * @date: 2018-08-22
 * @description:
 */
public class NoScrollViewPager extends ViewPager {

    private boolean isPagingEnabled;

    public NoScrollViewPager(Context context) {
        super(context);
    }

    public NoScrollViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public boolean onTouchEvent(MotionEvent event) {
        return this.isPagingEnabled && super.onTouchEvent(event);
    }

    public boolean onInterceptTouchEvent(MotionEvent event) {
        return this.isPagingEnabled && super.onInterceptTouchEvent(event);
    }

    public void scrollTo(int x, int y) {
        super.scrollTo(x, y);
    }

    public void setPagingEnabled(boolean pagingEnabled) {
        this.isPagingEnabled = pagingEnabled;
    }
}